package gizwits.overseaair.way.controldevice;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class Tset {
public static final String uri = "/api/test";
	
	/**
  		"deviceNumber",
		"factTemp",
		"setTemp",
		"lock",
		"swing",
		"power",
		"mode",
		"wind",
		"other",
	 * @param args
	 */
	
	public static void main(String[] args) {
//		Map<String, Object> params = new HashMap<>();
		String data = "{\"cmd\":\"enterprise_event_push\",\"delivery_id\":6884,\"event_type\":\"device_status_kv\",\"did\":\"utfgz6sdjVrtyTjvnCkcBB\",\"created_at\":1.46761734488199996948e+09,\"product_key\":\"813e7e10da864eab9968b4415e1b794b\",\"mac\":\"869267018853551\",\"group_id\":null,\"data\":{\"alarm_7\":0,\"interval_count\":120,\"alarm_13\":0,\"TDS_In\":86,\"filter_surplus_water_4\":0,\"filter_surplus_water_2\":6886,\"filter_surplus_water_3\":886,\"filter_surplus_water_1\":886,\"wash_set\":0,\"alarm_14\":0,\"alarm_16\":0,\"alarm_11\":0,\"alarm_10\":0,\"water_sort\":0,\"alarm_12\":0,\"interval_fee_1\":10,\"interval_fee_3\":20,\"interval_fee_2\":15,\"alarm_8\":0,\"alarm_1\":0,\"security_information\":\"01020304050607\",\"alarm_3\":0,\"alarm_2\":0,\"alarm_5\":0,\"alarm_4\":0,\"power\":0,\"alarm_6\":0,\"alarm_9\":0,\"recharge_amount\":0,\"treated_water_count\":19,\"interval_UL_1\":500,\"interval_fee\":30,\"interval_UL_2\":1000,\"TDS_Out\":4,\"temp_set\":0,\"signal\":31,\"alarm_15\":0,\"child_lock\":0,\"balance\":-25,\"filter_reset\":0}}";
		JSONObject control = JSONObject.parseObject(data);
//		params.put("data", control);
//		HttpKit.post(Address.air2_local+uri, params);
		//={"id":"579","wind":"low","mode":"fan","power":"y","swing":"n","lock":"mode,mode","setTemp":21}  
		//userId=dfbe7fd125174baab19b587b1d94ecf3 
		//System.out.println(JSON.parseObject("01"));
		String s = "{\"a-1\": [631], \"a95\": [], \"a96\": [], \"a97\": []}";
		String sKey = "a-1";
		String tKey = "a96";
		Integer[] did = {631};
		JSONObject objsJson = JSONObject.parseObject(s);
		if(objsJson.containsKey(sKey)){
			if(objsJson.containsKey(tKey)){
				JSONArray sarry = objsJson.getJSONArray(sKey);
				JSONArray tarry = objsJson.getJSONArray(tKey);
				//srry.addAll(new String[]{sarry});
				for(Integer d : did){
					for(int i=0;i<sarry.size();i++){
						if(Integer.valueOf(d).equals(sarry.get(i))){
							sarry.remove(i);
							tarry.add(d);
						}
					}
					
				}
				objsJson.put(tKey, tarry);
				objsJson.put(sKey, sarry);
			}
		}
		System.out.println(objsJson);
	}
}
